﻿/*
 * NetAddress.h
 */
#ifndef __GDK_NETADDRESS_H__
#define __GDK_NETADDRESS_H__

#include <gdk/core/Types.h>
#include <gdk/core/Mtbl.h>
#include <gdk/core/String.h>
#include <gdk/core/Json.h>
#include <gdk/net/Socket.h>


namespace gdk
{

	////////////////////////////////网络地址
	class GDK_NET_EXPORT NetAddress
	{
		DECLARE_MTBL(NetAddress)

	public:
		String		ip;
		uint16_t	port;

	public:
		NetAddress(void);
		bool isInvalid(void) const;
		bool operator ==(const NetAddress &addr) const;
		String toString(void) const;

		__INLINE__ bool operator !=(const NetAddress &addr) const { return !((*this) == addr); }
	};

	GDK_NET_EXPORT void convertPropertyToClass(const JsonValue &json, NetAddress &o) __THROW1;
	GDK_NET_EXPORT void convertPropertyToJson(const NetAddress &o, JsonValue &json) __THROW1;


} //namespace gdk



#endif //__GDK_NETADDRESS_H__

